package cn.lg.soar.general.service.impl;

import cn.lg.soar.database.base.service.impl.BaseServiceImpl;
import cn.lg.soar.general.entity.WebContent;
import cn.lg.soar.general.mapper.WebContentMapper;
import cn.lg.soar.general.model.WebContentVo;
import cn.lg.soar.general.service.IWebContentService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 页面位置内容
 * @author luguoxiang
 * @since 2023-03-19
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public class WebContentServiceImpl extends BaseServiceImpl<WebContentMapper, WebContent> implements IWebContentService {

    @Override
    public List<WebContentVo> voListByPositionId(Long positionId, Integer limit) {
        return list(
                Wrappers.<WebContent>lambdaQuery()
                        .eq(WebContent::getPositionId, positionId),
                limit
        ).stream()
                .map(WebContentVo::new)
                .collect(Collectors.toList());
    }

    @Override
    public boolean removeByPositionIds(Collection<Long> positionIds) {
        return remove(
                Wrappers.<WebContent>lambdaQuery()
                        .in(WebContent::getPositionId, positionIds)
        );
    }

}
